package com.ziroom.zifamily.zfms.common.util;

import com.ziroom.zifamily.zeus.json.JsonObjectTransform;
import com.ziroom.zifamily.zfms.pojo.obj.UserInfo;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

/**
 * 用户工具类，获取用户信息
 * <p>
 * <PRE>
 * <BR>    修改记录
 * <BR>-----------------------------------------------
 * <BR>    修改日期 2018-11-28        修改人 xgh         修改内容 新增部分请求方法
 * </PRE>
 *
 * @author cuiyh9
 * @version 1.0
 * @Date Created in 2018年11月19日 18:16
 * @since 1.0
 */
public class UserUtils {

    private UserUtils() {

    }

    public static UserInfo getUserInfo() {
        HttpServletRequest request = ((ServletRequestAttributes)      RequestContextHolder.getRequestAttributes()).getRequest();
//        UserInfo userInfo = JsonObjectTransform.json2Object(userInfojson, UserInfo.class);
        UserInfo userInfo = new UserInfo();
        userInfo.setUserName("张三");
        userInfo.setSystemCode("20120012");
        userInfo.setNickName("张三");
        return userInfo;
    }

    public static void main(String[] args) {
        String json = "{\"createTime\":\"2018-06-08 14:22:30\",\"email\":\"cuiyh9@ziroom.com\",\"groupIds\":[\"100451\"],\"id\":355,\"jobCodes\":[\"100426\"],\"lock\":false,\"menuList\":[],\"mobile\":\"13521263178\",\"modifyTime\":\"2018-11-26 11:46:00\",\"nickName\":\"崔玉辉\",\"permissionList\":[],\"roleList\":[],\"systemCode\":\"20120012\",\"type\":1,\"userName\":\"cuiyh9\"}\n";
        UserInfo userInfo = JsonObjectTransform.json2Object(json, UserInfo.class);
        System.out.println("userinfo:" + userInfo.getNickName());
    }


}
